from flask_wtf import FlaskForm
import wtforms
from wtforms import validators

class UserForm(FlaskForm):
    # 对填写的数据进行校验
    name = wtforms.StringField(
        label="账号",
    #     校验规则
        validators = [
            validators.Email(message="不符合邮箱规则"),
        ]
    )
    password = wtforms.PasswordField(
        label="密码",
        validators = [
            validators.Required(message="必填项")
        ]
    )

class AddPersonForm(FlaskForm):
    username = wtforms.StringField(
        validators = [
            validators.DataRequired(message = "必填项")
        ])
    password = wtforms.StringField(
        validators = [
            validators.Regexp("^[0-9]{6,8}$",message = "密码为6到8位数字")
        ])
    nickname = wtforms.StringField(
        validators = [
            validators.DataRequired(message = "必填项")
        ])
